package com.utils;

import com.joptimizer.functions.ConvexMultivariateRealFunction;
import com.joptimizer.functions.LinearMultivariateRealFunction;
import com.joptimizer.optimizers.JOptimizer;
import com.joptimizer.optimizers.OptimizationRequest;
import org.apache.commons.math3.linear.*;

import java.util.Iterator;

/**
 * Created with IntelliJ IDEA.
 * User: bigmar
 * Date: 12/22/14
 * Time: 11:39 AM
 * To change this template use File | Settings | File Templates.
 */
public class matrixSolver
{
    public static void main(String[] args) throws Exception {
        RealMatrix coefficients =
                new Array2DRowRealMatrix(new double[][] { { 1, 1,1, 1 }, { -0.9, 0.3, 0.1, 0.35 }, { 0.2, -0.9, 0.7, 0.35 },
                        { 0.6,0.3, -0.95, 0.05} },
                        false);
        DecompositionSolver solver = new LUDecomposition(coefficients).getSolver();
        RealVector constants = new ArrayRealVector(new double[] { 1, 0,0,0 }, false);
        RealVector solution = solver.solve(constants);


        for (int i=0; i<4; ++i)
            System.out.println(solution.getEntry(i));

    }
}
